package edu.sctu.xiangkun.day201506.day20150617;

import java.io.*;

/**
 * Created by user04 on 2015/6/17.
 */
public class DemoTwo {
    public void getFileStream(String name){
        int count  = 0;
        byte[] buffer = new byte[1024];
        try{
            File file = new File(name);
            File file1 = new File("D://hc1.txt");
            FileInputStream fileInputStream = new FileInputStream(file);
            FileOutputStream fileOutputStream = new FileOutputStream(file1);

         try{
             while((count = fileInputStream.read(buffer)) != -1){
                 String str = new String(buffer);
                 System.out.println(str);

                 fileOutputStream.write(buffer,0,count);
                 System.out.println(count);
             }

         }catch (IOException e) {
             e.printStackTrace();
         }

            try{
                fileInputStream.close();
                fileOutputStream.close();
            }catch(IOException e){
                e.printStackTrace();
            }

        }catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
